package com.cee.controller;

import com.cee.common.result.Result;
import com.cee.dto.CompletionDTO;
import com.cee.model.Completion;
import com.cee.service.CompletionService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/completion")
public class CompletionController {

    @Autowired
    private CompletionService completionService;


    @PostMapping("/list")
    public Result getCompletionList(@RequestBody CompletionDTO completionDTO){
        PageInfo pageInfo = completionDTO.getPageInfo();
        Page<CompletionDTO> Page = PageHelper.startPage(pageInfo.getPageNum(), pageInfo.getPageSize());

        completionService.getCompletionList(completionDTO);
        return Result.ok(new PageInfo<>(Page));
    }


    @GetMapping("/delete")
    public Result deleteCompletion(Integer id){
        completionService.deleteCompletion(id);
        return Result.ok();
    }

}
